<template>
  <div>
    <header>vue使用keep-alive保持滚动条位置的实现</header>
    <main id="content"></main>
    <footer></footer>
  </div>
</template>

<script>
export default {
  name: 'scrollBA',
  data() {
    // scrollBehavior 针对的是元素是#app 也就是window
    return {
      a: 'https://www.cnblogs.com/Qooo/p/14134896.html'
    };
  },
  activated() {
    const scrollTop = this.$route.meta.scrollTop;
    const $content = document.querySelector('#content');
    if (scrollTop && $content) {
      $content.scrollTop = scrollTop;
    }
  },
  methods: {}
};
</script>

<style lang="scss" scoped>

</style>
